'use strict';

function compute_median(collection) {
  //在这里写入代码
  collection.sort((a,b)=>{
    if(a<b) return 1;
    if(a>b) return -1;
    return 0;
  });
  let n=Math.floor(collection.length/2);
  if(collection.length%2==0){
    return Number((collection[n-1]+collection[n])/2);
  }
  return Number(collection[n]);
}

module.exports = compute_median;


